using System;
using System.Windows.Forms;

namespace CSW.Framework.UI.Binding
{
    /// <summary>
    /// Provider and interface for binding to various types of controls.
    /// </summary>
    public interface IBindableControl : IDisposable
    {
        /// <summary>
        /// Occurs when the control has validated.
        /// </summary>
        event EventHandler Validated;

        /// <summary>
        /// Gets the control this object wraps.
        /// </summary>
        /// <value>The control this object wraps.</value>
        Control Control { get; }

        /// <summary>
        /// Gets or sets the value of the control.
        /// </summary>
        /// <value>The value of the control.</value>
        object Value { get; set; }

        /// <summary>
        /// Gets the name of the control.
        /// </summary>
        /// <value>The name of the control.</value>
        string Name { get; }

        /// <summary>
        /// Gets or sets a value indicating whether the control is enabled.
        /// </summary>
        /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
        bool Enabled { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the control is read only.
        /// </summary>
        /// <value><c>true</c> if read only; otherwise, <c>false</c>.</value>
        bool ReadOnly { get; set; }

        /// <summary>
        /// Focuses the control.
        /// </summary>
        void Focus();

        /// <summary>
        /// Gets the tab index.
        /// </summary>
        /// <value>The tab index.</value>
        int TabIndex { get; }

        /// <summary>
        /// Gets or sets the maximum string length.
        /// </summary>
        /// <value>The maximum string length.</value>
        int MaxLength { get; set; }

        /// <summary>
        /// Sends the <see cref="Validated"/> event.
        /// </summary>
        void SendValidated();
    }
}